﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MainView.Model.sys
{
    class UseMemory
    {
        public double GetProcessUsedMemory()
        {
            double usedMemory = 0;
            try
            {
                usedMemory = Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0;
                Console.WriteLine("内存使用量: " + usedMemory.ToString("0.0") + " M");
            }

            catch (Exception ex)
            {
                Console.WriteLine("获取内存使用错误 " + ex.ToString());
            }
            return usedMemory;
        }
    }
}
